//_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/.
// 			VisualNovelToolkit		     /_/_/_/_/_/_/_/_/_/.
// Copyright ©2013 - Sol-tribe.	/_/_/_/_/_/_/_/_/_/.
//_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/.

using UnityEngine;
using System.Collections.Generic;

/// <summary>
/// PlayTransition Node.
/// </summary>
//[ AddComponentMenu("ViNo/Nodes/PlayTransition") ]
public class PlayTransitionNode : ViNode {
	[ Range( 0.1f , 10f )]
	public float waitSec = 1f;

	public bool _BEGIN;
	public bool _END;

	void Start(){
		
	}

	public void BeginPreview(){
		if( ITransition.Instance != null ){
			ITransition.Instance.BeginTransition();
		}
	}

	public void EndPreview(){
		if( ITransition.Instance != null ){
			ITransition.Instance.EndTransition();
		}
	}

	public override void ToByteCode( ByteCodes code ){
		List<byte> byteList = new List<byte>();
		
//		AddNodeCodeWithTag( byteList , name );
		AddNodeCode( byteList );
		
		if( _BEGIN ){			
			byteList.Add( Opcode.BEGIN_TRANSITION );
		}

		CodeGenerator.GenerateWaitCode( byteList , waitSec );

		if( _END ){			
			byteList.Add( Opcode.END_TRANSITION );
		}

		code.Add( byteList.ToArray() );		
		
		// ToByteCode this Children.
		ToByteCodeInternal( code );				
	}

}
